#pragma once
#include <string>
#include <cstdlib>
class Code
{
public:
    int code(std::string &x)
    {
        int pos = x.find(" ");
        if (pos != std::string::npos)
        {
            _x = atoi(x.substr(0, pos).c_str());
            x.erase(0, pos + 1);
        }
        pos = x.find(" ");
        if (pos != std::string::npos)
        {
            _op = *(x.substr(0, pos).c_str());
            x.erase(0, pos + 1);
        }
        pos += 1;
        _y = atoi(x.substr(0, pos).c_str());
        x.clear();
        return start();
    }

private:
    int start()
    {
        int n = 0;
        switch (_op)
        {
        case '+':
            n = _x + _y;
            break;
        case '-':
            n = _x - _y;
            break;
        case '/':
            n = _x / _y;
            break;
        case '*':
            n = _x * _y;
            break;
        }
        return n;
    }

private:
    int _x;
    char _op;
    int _y;
};